﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace VisualExamEngine
{
    public partial class frmSectionName : Form
    {
        private frmExamProperties ExamProps;
        private frmMdiChild mdi_child;

        public frmSectionName(frmExamProperties ExamProps, frmMdiChild child)
        {
            InitializeComponent();

            this.ExamProps = ExamProps;
            this.mdi_child = child;
        }

        /// <summary>
        /// DateTime: 5/12/15 8:00 PM
        /// Author: Mike Hartwig
        /// Purpose: Close the form.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        /// <summary>
        /// DateTime: 5/12/15 9:00 PM
        /// Author: Mike Hartwig
        /// Purpose: Add the section to the listbox
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (ExamProps.lstSections.Items.Contains(this.txtSectionName.Text) == true)
            {
                MessageBox.Show("There is already a section by this name.");
            }
            else
            {
                ExamProps.lstSections.Items.Add(this.txtSectionName.Text);

                //add the section to exam
                clsExam exam = (clsExam)mdi_child.Tag;

                exam.Sections.Add(this.txtSectionName.Text);

                //close the form
                this.Close();
            }
        }
    }
}
